<?php

namespace App\Http\Controllers\Api\Rbac;

use App\Http\Controllers\Controller;
use App\Rep\Rbac\UserRep;
use Illuminate\Http\Request;

class User extends Controller
{
    protected $rep;

    public function __construct(Request $request)
    {
        $this->rep = new UserRep();
    }
    //获取后台用户列表
    public function getUserList(Request $request){
        $params = $request->all();
        $list = $this->rep->getUserListRep($params);
        return re(0,$list,'success');
    }

    //添加用户
    public function createUser(Request $request){
        $params = $request->all();
        $data = $this->rep->createUserRep($params);
        return re($data['code'],$data['data'],$data['msg']);
    }
    //修改用户状态
    public function setUserStatus(Request $request){
        $params = $request->only(['id','status']);
        $data = $this->rep->setUserStatusRep($params);
        return re(0,$data,'success');
    }

    //获取账号详情
    public function getUserInfo(Request $request){
        //$params = $request->only(['user_id','role_id','user_info']);
        $params = $request->all();
        $data = $this->rep->getUserInfoRep($params);
        return re(0,$data,'success');
    }
}
